#include "yzjfile.h"

YZJFile::YZJFile()
{
    fileName = "record.yzj";
    file.setFileName(fileName);

}

//QFile YZJFile::OpenFile(QString fileName){
//    QFile file(fileName);
//    if(!file.open(QIODevice::Append | QIODevice::ReadWrite | QIODevice::Text)){
//        QMessageBox msgBox;
//        msgBox.setText("文件无法打开");
//        msgBox.exec();
////        QMessageBox::warning(this,QObject::tr("错误"),QObject::tr("无法打开文件")
////                             , QMessageBox::Ok
////                             , QMessageBox::NoButton);
//        exit(1);
//    }
//    return file;
//}

FILE *YZJFile::OpenFile(const char *fn, const char *mode){
    FILE *fp = fopen(fn, mode);
    if(fp == NULL){
        printf("open file wrong\n");
        exit(1);
    }else{
        return fp;
    }
}

int YZJFile::SeekPosition(FILE *fp, long offset, int whence){
    int flag = 1;
    flag = fseek(fp, offset, whence);
    if(flag != 0){
        printf("seek file error\n");
        exit(1);
    }
    return flag;
}

void YZJFile::CloseFile(FILE *fp){
    fclose(fp);
}
